package com.example.adminbase.web;

import com.example.adminbase.domain.SysUser;
import com.example.adminbase.domain.UserQueryParam;
import com.example.adminbase.service.CrudService;
import com.example.adminbase.service.SysUserService;
import com.github.pagehelper.Page;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/sysUser")
class SysUserController extends CrudControllerAdapter<String, SysUser> {

    /**
     * This is generated by MyBatis Generator, do not modify.
     * @mbg.generated
     */
    @Autowired
    private SysUserService service;

    /**
     * This is generated by MyBatis Generator, do not modify.
     * @mbg.generated
     */
    @Override
    public CrudService<String, SysUser> getService() {
        return service;
    }

    @Override
    @RequiresPermissions("user:view")
    public SysUser findById(String id) {
        return super.findById(id);
    }

    @RequestMapping("/findBy")
    @ResponseBody
    @RequiresPermissions("user:view")
    public Page<SysUser> findBy(@RequestBody UserQueryParam userQueryParam) {
        return service.findBy(userQueryParam);
    }
}
